package com.yijumao.shop.controller;

import com.ramostear.captcha.HappyCaptcha;
import com.ramostear.captcha.support.CaptchaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author konley
 * @date 2020-11-09 11:37
 * 验证码控制器
 */
@Controller
public class HappyCaptchaController {
    // 生成验证码
    @RequestMapping("/captcha")
    public void createCaptcha(HttpServletResponse response, HttpServletRequest request){
        // 使用HappyCaptcha创建验证码
        HappyCaptcha.require(request,response).length(4).type(CaptchaType.NUMBER).build().finish();
    }
}
